<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
jimport ( 'joomla.application.component.view' );

class JAJobBoardViewJAJobBoard extends JAView {
	/**
	 * Display the view
	 */
	function display($tmpl = null) {
		
		switch (JRequest::getVar ( 'layout', 'statistics' )) {
			case 'statistics' :
				$this->getStatistics ();
				break;
			case 'documents' :
				checkPermission_Administrator('view_license');
				$this->displayDocument ();
				break;			
			case 'quicksearch' :
				$this->displayQuickSearch ();
				break;
		}
		$this->setLayout ( JRequest::getVar ( 'layout', 'statistics' ) );
		parent::display ( $tmpl );
	}
	
	function getStatistics() {
		$this->displayQuickSearch ();
		$statistics = $this->get ( 'StatisticsInfo' );
		$this->assignRef ( 'statistics', $statistics );
	}
	
	function displayDocument() {
		$key = $this->get ( 'Key' );
		$this->assignRef ( 'key', $key );
	}
	
	function displayQuickSearch() {
		$search_option = $this->get ( 'SearchOption' );
		
		$this->assignRef ( 'searchOption', $search_option );
	}
		
	function menu() {
		global $JBVERSION;

		$latest_version ='';
		$version_link = JobBoardConstant::get_Version_Link();
		$layout = JRequest::getVar ( 'layout', 'statistic' );
		$cid = JRequest::getVar ( 'cid' );
		if (is_array ( $cid )) {
			JArrayHelper::toInteger ( $cid );
			$cid = $cid [0];
		}
				
		$latest_version = $this->get ( 'LatestVersion' );
		if ($latest_version)
		{
			$version_link['latest_version']['info'] = 'http://wiki.joomlart.com/wiki/JA_Job_Board/Overview';
			$version_link['latest_version']['upgrade'] = 'http://www.joomlart.com/forums/downloads.php?do=cat&id=130';
		}
		else 
		{
			$version_link['latest_version']['info'] = '';
			$version_link['latest_version']['upgrade'] = '';
		}
		$xml =& JFactory::getXMLParser( 'simple' );
     	$file = JPATH_COMPONENT.DS.'com_jajobboard.xml';
     	
		$xml->loadFile( $file );
		$out =& $xml->document;
		if($out == false){
			$current_version = $JBVERSION;		
		}else{			
			$allComments = $out->children();
			foreach ( $allComments as $blogpost) {							
				if($blogpost->name() == "version"){					
					$current_version = $blogpost->data();
					break;
				}
			}			
		}
		?>
		<div class="t">
		<div class="t">
		<div class="t"></div>
		</div>
		</div>
		<div class="m">
		<ul id="submenu">
			<li><a href="index.php?option=com_jajobboard&layout=statistics"
				class="<?php
				if ($layout == null || $layout == 'statistics')
					echo 'active'?>">
										<?php
				echo JText::_ ( 'Statistics' );
				?>
									</a></li>
			<li><a href="index.php?option=com_jajobboard&layout=documents"
				class="<?php
				if ($layout == 'documents')
					echo 'active'?>">
										<?php
				echo JText::_ ( 'Support & Documents' );
				?>
									</a></li>
			
			<li style="float: right">
				<?php 
				if($latest_version==''){
					 echo JText::_ ( 'Version' ). ' <b>'.$current_version.'</b>';
				}elseif($latest_version!='' && $latest_version==$current_version){
					echo JText::_('Your version'). ': <b><a href="'.$version_link['current_version']['info'].'" target="_blank">'.$current_version.'</a></b>&nbsp;&nbsp;'.JText::_ ( 'Latest version' ).': <b><a href="'.$version_link['latest_version']['info'].'" target="_blank">'.$latest_version.'</a></b>&nbsp;&nbsp;<font color="Blue"> <i>('.JText::_ ( 'System running the latest version.' ).')</i></font>'; 
				}elseif($latest_version!='' && $latest_version!=$current_version){
					echo JText::_('Your version'). ': <b><a href="'.$version_link['current_version']['info'].'" target="_blank">'.$current_version.'</a></b>&nbsp;&nbsp;'.JText::_ ( 'Latest version' ).': <b>';
					echo isset($version_link['latest_version'])?'<a href="'.$version_link['latest_version']['info'].'" target="_blank">'.$latest_version.'</a>':$latest_version;echo '</b>&nbsp;&nbsp;<span style="background-color:rgb(255,255,0);color:Red;font-weight:bold;">'.JText::_('New version available!'). '</span>';
					if (isset($version_link['latest_version'])) echo '<a target="_blank" href="'.$version_link['latest_version']['upgrade'].'" title="'.JText::_('Click here to download latest version').'">'.JText::_ ( 'Upgrade now' ).'</a>';
				}?>					
			</li>
		</ul>
		<div class="clr"></div>
		</div>
		<div class="b">
		<div class="b">
		<div class="b"></div>
		</div>
		</div>
<?php
	}

}
?>
